package factory;

import factory.method.*;

import java.util.Scanner;

public class ComputerTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入数字1：");
        double num1 = input.nextDouble();
        System.out.print("请输入数字2：");
        double num2 = input.nextDouble();
        System.out.println("请选择你要进行的运算：(1.加，2减，3.乘，4，除):");
        int num = input.nextInt();
        Computer computer = null;
        ComputerFactory factory = null;
        double result1 = 0;

        if(num == 1){
            factory = new AddFactory();
            computer = factory.createComputer();
            result1 = computer.getResult(num1, num2);
            System.out.println("运行结果：" + result1);
        }else if(num == 2){
            factory = new SubtractFactory();
            computer = factory.createComputer();
            result1 = computer.getResult(num1, num2);
            System.out.println("运行结果：" + result1);
        }else if(num == 3){
            factory = new MultiplyFactory();
            computer = factory.createComputer();
            result1 = computer.getResult(num1, num2);
            System.out.println("运行结果：" + result1);
        }else if(num == 4){
            factory = new ExceptFactory();
            computer = factory.createComputer();
            result1 = computer.getResult(num1, num2);
            System.out.println("运行结果：" + result1);
        }
    }
}
